﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Caching;
using System.Globalization;

namespace Barbar.MapReport.DataSource {
  internal static class RegionGeometryCache {
    public static Polygon GetRegionGeometry(string regionId, ZoomLevel zoomLevel) {
      CacheManager manager = CacheFactory.GetCacheManager("RegionCacheManager");
      string key = String.Format(CultureInfo.InvariantCulture, "{0};{1}", zoomLevel.Id, regionId);
      return (Polygon)manager.GetData(key);
    }

    public static void SetRegionGeometry(string regionId, ZoomLevel zoomLevel, Polygon polygon) {
      CacheManager manager = CacheFactory.GetCacheManager("RegionCacheManager");
      string key = String.Format(CultureInfo.InvariantCulture, "{0};{1}", zoomLevel.Id, regionId);
      manager.Add(key, polygon, CacheItemPriority.NotRemovable, null, null);
    }
  }
}
